package trabajoISW2.presentation.shared;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import trabajoISW2.data.BookDAO;
import trabajoISW2.data.IBookDAO;
import trabajoISW2.domain.implementations.Author;
import trabajoISW2.domain.implementations.Book;
import trabajoISW2.domain.implementations.Publisher;
import trabajoISW2.domain.implementations.Subject;

public class BookMapper {
	
	

	public static BookDTO createDTO(Book b) {
		BookDTO dto = new BookDTO(b.getIsbn(), b.getTitle(), b.getLanguage(),
				b.getAuthor().getName().concat(" "+b.getAuthor().getSurname()),
				b.getPublisher().getName(),
				b.getSubject().getName(), b.getSummary(),
				b.getPrice(), b.getYear());
		return dto;
	}

	public static Book updateDomainObject(BookDTO dto) {
		return new Book(dto.getIsbn(), dto.getTitle(), dto.getPrice(), dto.getSummary(), dto.getLanguage(), dto.getYear(), null, null, null);
	}
	

}
